<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/static/lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="/static/css/public.css" media="all">
    <style>
        body {
            background-color: #ffffff;
        }
    </style>
</head>
<body>
<div class="layui-form layuimini-form">
    <div class="layui-form-item">

        <label class="layui-form-label ">导出模板:</label>
        <div class="layui-input-inline">
            <select  name="exportId" id="exportId" lay-search="">
            </select>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认导出</button>
        </div>
    </div>
</div>
<script src="/static/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script src="/static/lib/jquery-3.4.1/jquery-3.4.1.min.js" charset="utf-8"></script>
<script src="/static/lib/jq-module/jquery.particleground.min.js" charset="utf-8"></script>
<script src="/static/js/common.js"></script>
<script>
    let id = $.common.getUrlParam("id");
    layui.use(['form',  'element', 'layer'], function () {
        var form = layui.form;
        //初始化下拉框 客人
        let callback = {
            onSuccess: function (result) {
                if (result.code == '0') {
                    $('#exportId').append(new Option('请选择', '', true));// 下拉菜单里添加元素
                    $.each(result.data, function (index, item) {
                        let option = new Option(item.remark, item.id);
                        $('#exportId').append(option);// 下拉菜单里添加元素
                    });
                } else {
                    $.common.showErrorMessage(result.message)
                    return false;
                }
            }
        };
        $.xAjax('/exportModelConfig/select/QUOTATION', 'POST', JSON.stringify({}), callback);

        //初始化下拉框
        form.render("select");
        //监听提交
        form.on('submit(saveBtn)', function (data) {

            if(data.field.exportId){
                url = '/quotation/export/' + id+'/'+data.field.exportId;
                console.log(url)
                window.location.href = url;
            }else{
                $.common.showErrorMessage("请选择模板");
                return false;
            }
        });

    });
</script>
</body>
</html>